const http=require('http');
const querystring=require('querystring');

let doc='<form method="post">info: <input name="info"/><input type="submit"/></form>';
http.createServer(function(request,response){
    let form='';
    request.on('data',chunk=>form+=chunk);
    request.on('end',()=>{
        form=querystring.parse(form);
        response.writeHead(200,{'Content-Type':'text/html; charset=utf-8'});
        if(form.info){
            response.write(form.info);
        }else{
            response.write(doc);
        }
        response.end();
    });
}).listen(8080);
